<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>
    <!-- content starts -->
    <blockquote class="layui-elem-quote"><{$action}></blockquote>

    <div class="tabMainCont">
        <!--star会员管理-->
        <fieldset class="layui-elem-field">
            <legend>筛选</legend>
            <div class="layui-field-box">
                <form class="layui-form layui-form-pane1" method="post" action="/tiku/test_volume">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <select name="subject_id" id="subject_id">
                                <option value="0">选择科目</option>
                                <{foreach from=$subject item=item}>
                                    <option value="<{$item.id}>" <{if  $conditions.subject_id == $item.id}>selected<{/if}>><{$item.title}></option>
                                <{/foreach}>
                            </select>
                        </div>

                        <div class="layui-inline">
                            <input type="text" class="layui-input" style="width:200px;" placeholder="组卷名称" value="<{if  $conditions.test_volume_name != 0}><{$conditions.test_volume_name}><{/if}>"  name="test_volume_name" />
                        </div>

                        <div class="layui-inline">
                            <button type="submit" class="layui-btn">搜索</button>
                            <a class="layui-btn" href="/tiku/add_test_volume"><i class="layui-icon"></i> 新增试卷</a>
                        </div>
                    </div>
                </form>
            </div>
        </fieldset>
        <table class="layui-table" lay-even lay-skin="row">
            <thead>
                <tr>
                    <th>序号</th>
                    <th>组卷名称</th>
                    <th>添加时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <{foreach from=$test_volume_list item=item}>
                <tr>
                    <td class="tal"><{$item.id}></td>
                    <td class="tal not_lb"><{$item.name}></td>
                    <td class="tal not_lb"><{$item.add_time|date_format:'%Y-%m-%d  %H:%M:%S'}></td>
                    <td class="tal not_lb">
                        <div class="colorBtn">
                            <{if isset($item.type.1) AND $item.type.1 == 1}>
                                 <a href="javascript:;">已发布到考情速递</a>
                            <{else}>
                                 <a href="javascript:;" class="publish" type="1" volume_id="<{$item.id}>">发布到考情速递</a>
                            <{/if}>
                            <{if isset($item.type.2) AND $item.type.2 == 1}>
                                 <a href="javascript:;">已发布到真题冲刺</a>
                            <{else}>
                                 <a href="javascript:;" class="publish" type="2" volume_id="<{$item.id}>">发布到真题冲刺</a>
                            <{/if}>
                            <a href="/tiku/delete_volume/<{$item.id}>">删除组卷</a>
                        </div>
                    </td>
                </tr>
            <{/foreach}>
        </table>
        <div class="pages p-tb20" style="text-align:right;">
            <!-- <div class="l">
                <a href="javascript:;" class="zent-btn">你想要的按钮</a>
            </div> -->
            <{$pagination}>
        </div>

    </div>
    <div class="layui-box layui-laypage layui-laypage-default">
        <{$pagination}>
    </div>      
<{include file="public_html/footer.html"}>

<script>
    layui.use(['form', 'jquery', 'layedit'], function(){
        var layedit = layui.layedit,form = layui.form(),$ = layui.jquery;
        $(".publish").click(function(){
            var _this = $(this);
            var volume_id = $(this).attr("volume_id");
            var type = $(this).attr("type");
            layer.prompt({title: '请输入该试卷的答题时长（单位：分钟）', formType: 3}, function(text, index){
                if(isNaN(text)){
                    layer.msg("时长必须是数字！", {icon:5, anim: 6});
                    return false;
                }
                layer.close(index);
                $.ajax({
                    type: "POST",
                    url: "/tiku/save_volume_publish",
                    dataType:"json",
                    data:{'type':type,'volume_id':volume_id, 'timeout':text},
                    success: function(result){
                        // layer.close(ii);
                        if(result.error == 0){
                            layer.msg(result.msg, {icon:6});
                            _this.text(result.msg);
                            _this.unbind("click");
                        }else{
                            layer.msg(result.msg, {icon:5});
                        }
                    }
                });
            });
        })
        // /classes/add_home_work
        $(".zpublish").click(function(){
            $(".zpublish").attr("id", "");
            $(this).attr("id", "now");
            var _this = $(this);
            var volume_id = $(this).attr("volume_id");
            var type = $(this).attr("type");
            layer.open({
                type: 2,
                title: '发布组卷',
                shadeClose: true,
                shade: 0.8,
                area: ['90%', '90%'],
                maxmin: true,
                content: '/tiku/test_volume_publish/'+volume_id+"/"+type //iframe的url
            }); 
        })
    });
</script>
</body>
</html>
